//
//  MePushMgr.m
//  MeLive
//
//  Created by liulei on 2017/5/11.
//  Copyright © 2017年 liulei. All rights reserved.
//

#import "MePushMgr.h"


@implementation MePushMgr

static MePushMgr *_sharedInstance = nil;


+ (instancetype)sharedInstance
{
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        _sharedInstance = [[MePushMgr alloc] init];
    });
    return _sharedInstance;
}

- (instancetype)init
{
    if (self = [super init])
    {
    }
    return self;
}



- (void)getPusherUrlWithUserid:(NSString *)userId isMobileShow:(NSString *)isMobileShow orientation:(NSString *)orientation handler:(RequestPusherUrlHandler)handler{
    self.userId = userId;
    
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:NullStringToString(userId) forKey:@"userId"];
    [parameters setObject:NullStringToString(isMobileShow) forKey:@"isMobileShow"];
    [parameters setObject:NullStringToString(orientation) forKey:@"orientation"];
    
    SetHUDStartText(@"加载中");
    
    [MeUtil dictionary2JsonData:parameters];
    
    [MeNetworkHelper POST:@"http://api.cshuax.com/v1/live/new-channel" parameters:parameters success:^(id responseObject) {

        NSDictionary *resultDict = responseObject[kDataListKey];
        MeLiveInfoModel *liveInfo = [[MeLiveInfoModel alloc] initWithDictionary:resultDict error:nil];
        SetHUDHidden;
        handler(0, liveInfo);
        SetHUDHidden;
    } failure:^(NSError *error) {
        SetHUDHidden;
    }];
}


- (void) getPushUrlForLinkMic:(NSString*)userId title:(NSString*)title coverPic:(NSString*)coverPic nickName:(NSString*)nickName headPic:(NSString*)headPic location:(NSString*)location handler:(RequestLinkMicPusherUrlHandler)handler {
    self.userId = userId;
    
}

@end
